package com.gskj.educms.controller;


import com.gskj.commonutils.ResultJson;
import com.gskj.educms.entity.CrmBanner;
import com.gskj.educms.service.ICrmBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Connor-G
 * @since 2020-05-20
 * <p>
 * 前台banner调用接口
 */
@RestController
@RequestMapping("/educms/bannerfront")
@CrossOrigin
public class BannerFrontController {


    @Autowired
    private ICrmBannerService iCrmBannerService;

    /***
     *  查询 banner 列表
     * @return
     */
    @Cacheable(value = "banner", key = "'selectIndexList'")  // 将方法返回的数据保存到 缓存中
    @GetMapping("/get/banner/page")
    public ResultJson getBannerList() {

        // 涉及到 redis缓存
        List<CrmBanner> bannerList = iCrmBannerService.getBannerList();

        return ResultJson.success().data("bannerList", bannerList);
    }
}

